<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 14-5-6
 * Time: 下午4:41
 */
class MarticleUser extends CI_Model{
    function __construct(){
        parent::__construct();
    }


    function addArticleUid($id,$uid)
    {
        $this->deleteArticleUid($id);

        $uids = explode(',',$uid);

        if(!empty($uids)){
            foreach($uids as $value){
                $sqlArr[] = "($value,$id)";
            }
            $sql = "INSERT INTO `tbarticle_user`(`uid`,`article_id`)VALUES".implode(',',$sqlArr);
            $this->db->query($sql);
        }
        return $this->db->insert_id();
    }

    function deleteArticleUid($id)
    {

        $this->db->delete('tbarticle_user', array('article_id' => $id));

    }
}